<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title></title>
    <link href="${basePath}/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="${basePath}/css/scrollbar.css">
    <script src="${basePath}/js/jquery-1.10.2.js"></script>
    <script type="text/javascript">
    	$(function(){
    		var w = $("#page").width();
    		$("#pagediv").css("width",w);
    		$("#btn-${currentPage}").attr("class","btn btn-primary");
    	});
    	function gotoPage(currentPage){
    		$("#example").val("${example}");
    		$("#currentPage").val(""+currentPage);
    		$("form").submit();
    	}
    	function find(){
    		$("#currentPage").val("1");
    		$("form").submit();
    	}
    </script>
  </head>
  <body>
  	<div style="width: 85%;margin: 0px auto;">
  		<form action="${basePath}/allpeople" method="post">
  		<div class="input-group input-group-lg" style="width: 100%;margin: 20px auto 20px auto;">
	      <div class="input-group-btn">
	        <button type="button" class="btn btn-default dropdown-toggle" onclick="location.href='${basePath}/friend'"><span class="glyphicon glyphicon-cog" aria-hidden="true"></span></button>
	      </div>
	      <input type="text" class="form-control" id="example" name="example" value="${example}" placeholder="找陌生人">
	      <input type="hidden" name="currentPage" id="currentPage" value="${currentPage}">
	      <div class="input-group-btn">
	        <button type="button" class="btn btn-primary dropdown-toggle" onclick="find()">搜索</button>
	      </div>
	    </div>
	    <ul class="list-group" style="width: 100%;margin: 20px auto 20px auto;min-height: 300px">
		    <c:forEach items="${friendList}" var="friend">
			  <li class="list-group-item" onclick="location.href='${basePath}/allpeopleinfo/${friend.id}'" style="cursor: pointer;">
			  	<img src="${headimagePath}/${friend.headimage}" width="40" height="40" class="img-rounded">
			  	<span class="badge" style="max-width: 50%;text-overflow:ellipsis;overflow: hidden;">${friend.nickname }</span>
			  </li>
			</c:forEach>
		</ul>
		<div style="margin: 20px auto 20px auto;" id="pagediv">
			<div class="btn-group btn-group-lg" id="page">
				  <button type="button" class="btn btn-default" onclick="gotoPage(${currentPage-1})">&laquo;</button>
				  <c:forEach begin="1" end="${totalPage}" var="p">
				 	 <button id="btn-${p}" type="button" class="btn btn-default" onclick="gotoPage(${p})">${p}</button>
				  </c:forEach>
				  <button type="button" class="btn btn-default" onclick="gotoPage(${currentPage+1})">&raquo;</button>
			</div>
		</div>
		</form>
	</div>
    <script src="${basePath}/js/jquery.min.js"></script>
    <script src="${basePath}/js/bootstrap.min.js"></script>
  </body>
</html>